package grouplife::Controller::Category;
use Moose;
use namespace::autoclean;
use Catalyst::Request::Upload;
use String::Random;
use File::Basename;
use Image::Magick::Thumbnail::Fixed;
use Catalyst::Log;

use Data::Dumper;
use Catalyst qw/
Session
Session::Store::FastMmap
Session::State::Cookie
/;


BEGIN {extends 'Catalyst::Controller'; }


sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    $c->response->body('Matched grouplife::Controller::Category in Category.');
}

sub base :Chained('/') :PathPart('category') :CaptureArgs(0) {
	my ($self, $c) = @_;

	$c->stash(resultset => $c->model('DB::Category'));

	$c->log->debug('*** INSIDE BASE METHOD ***');
}

sub object :Chained('base') :PathPart('id') :CaptureArgs(1) {
	my ($self, $c, $id) = @_;

	$c->stash(object => $c->stash->{resultset}->find($id));

	die "Tuan $id not found!" if !$c->stash->{object};

	$c->log->debug("*** INSIDE OBJECT METHOD for obj id=$id ***");
}

sub search_stores:Chained('object') :PathPart('search_stores') :Args(0) {
	my ($self, $c) = @_;
        $c->stash(login_user => $c->session->{login_user});

        $c->stash(cats => [$c->model('DB::Category')->all]);
       	$c->stash(category => $c->stash->{object});

        $c->stash(template => 'stores/list.tt2');

}

=head1 AUTHOR

lijie,,,

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__->meta->make_immutable;

